package com.study.talk.data.model;

import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;

import com.study.talk.netty.message.response.GroupMessageResponse;
import com.study.talk.netty.message.response.GroupMessageSelfResponse;
import com.study.common.annotation.Desc;

@Entity(tableName = "group_message_record")
public class GroupMessageRecord {

    @PrimaryKey(autoGenerate = true)
    @ColumnInfo(name = "id")
    private Integer id;

    @ColumnInfo(name = "group_id")
    private Integer groupId;

    @ColumnInfo(name = "user_id")
    private Integer userId;

    @Desc("用户名称")
    @ColumnInfo(name = "username")
    private String username;

    @Desc("用户昵称")
    @ColumnInfo(name = "nickname")
    private String nickname;

    @Desc("用户头像")
    @ColumnInfo(name = "avatar")
    private String avatar;

    @Desc("消息内容")
    @ColumnInfo(name = "content")
    private String content;

    @Desc("消息时间")
    @ColumnInfo(name = "date_time")
    private String dateTime;

    @Desc("消息类型")
    @ColumnInfo(name = "message_type")
    private Integer messageType;

    @ColumnInfo(name = "self")
    private Boolean self;

    @ColumnInfo(name = "read")
    private Boolean read;

    public GroupMessageRecord() {
    }


    @Ignore
    public GroupMessageRecord(GroupMessageResponse groupMessageResponse, Boolean self,Boolean read){
        this.userId = groupMessageResponse.getSendUserId();
        this.avatar = groupMessageResponse.getAvatar();
        this.content = groupMessageResponse.getContent();
        this.username = groupMessageResponse.getSendUserName();
        this.nickname = groupMessageResponse.getSendUserNickName();
        this.groupId = groupMessageResponse.getGroupId();
        this.dateTime = groupMessageResponse.getDateTime();
        this.messageType = groupMessageResponse.getMessageType();
        this.self = self;
        this.read = read;
    }
    @Ignore
    public GroupMessageRecord(UserInfo userInfo, GroupMessageSelfResponse messageSelfResponse, Boolean self) {
        this.userId = userInfo.getId();
        this.username = userInfo.getUsername();
        this.nickname = userInfo.getNickName();
        this.avatar = userInfo.getAvatar();
        this.content = messageSelfResponse.getContent();
        this.groupId = messageSelfResponse.getGroupId();
        this.messageType = messageSelfResponse.getMessageType();
        this.self = self;
        this.read = true;
        this.dateTime = messageSelfResponse.getDateTime();
    }
    @Ignore
    public GroupMessageRecord(Integer userId, String username, String nickname, String avatar, String content, Integer groupId,String dateTime, Integer messageType, Boolean self) {
        this.userId = userId;
        this.username = username;
        this.nickname = nickname;
        this.avatar = avatar;
        this.content = content;
        this.groupId = groupId;
        this.dateTime = dateTime;
        this.messageType = messageType;
        this.self = self;
    }
    @Ignore
    public GroupMessageRecord(Integer id, Integer groupId, Integer userId, String username, String nickname, String avatar, String content, String dateTime, Integer messageType, Boolean self, Boolean read) {
        this.id = id;
        this.groupId = groupId;
        this.userId = userId;
        this.username = username;
        this.nickname = nickname;
        this.avatar = avatar;
        this.content = content;
        this.dateTime = dateTime;
        this.messageType = messageType;
        this.self = self;
        this.read = read;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Boolean getRead() {
        return read;
    }

    public void setRead(Boolean read) {
        this.read = read;
    }

    public Integer getGroupId() {
        return groupId;
    }

    public void setGroupId(Integer groupId) {
        this.groupId = groupId;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getDateTime() {
        return dateTime;
    }

    public void setDateTime(String dateTime) {
        this.dateTime = dateTime;
    }

    public Integer getMessageType() {
        return messageType;
    }

    public void setMessageType(Integer messageType) {
        this.messageType = messageType;
    }

    public Boolean getSelf() {
        return self;
    }

    public void setSelf(Boolean self) {
        this.self = self;
    }

    @NonNull
    @Override
    public String toString() {
        return "GroupMessageRecord{" +
                "id=" + id +
                ", groupId=" + groupId +
                ", userId=" + userId +
                ", username='" + username + '\'' +
                ", nickname='" + nickname + '\'' +
                ", avatar='" + avatar + '\'' +
                ", content='" + content + '\'' +
                ", dateTime='" + dateTime + '\'' +
                ", messageType=" + messageType +
                ", self=" + self +
                ", read=" + read +
                '}';
    }
}
